package com.lyfei.ydc.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lyfei.ydc.domain.entity.Spu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("searchService")
public class SearchService {
    @Autowired
    private SpuService spuService;

    public IPage<Spu> search(String q, Integer  page, Integer size){
        return spuService.page(new Page<>(page, size), new LambdaQueryWrapper<Spu>()
                .like(Spu::getTitle, q)
                .or()
                .like(Spu::getSubTitle, q));
    }
}
